package org.sourcecode.common.cas.client;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * httpSession impl
 * @author root
 *
 */
public class HttpSessionProvider implements SessionProvider{
	
	public Object getSession(HttpServletRequest request, String name) {
		HttpSession session = request.getSession(false);
		if (session != null) {
			return  session.getAttribute(name);
		} else {
			return null;
		}
	}

	public void setSession(HttpServletRequest request, String name, Object value) {
		HttpSession session = request.getSession();
		session.setAttribute(name, value);
	}

	public String getSessionId(HttpServletRequest request) {
		return request.getSession().getId();
	}

	public void invalidate(HttpServletRequest request) {
		request.getSession().invalidate();
	}

	public void delSession(HttpServletRequest request, String name) {
		request.getSession().removeAttribute(name);
		
	}
}
